import { BgLabelToolTip } from "../../common/tooltip/BgLabelToolTip";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { SPetInfo } from "../../../../../Message/Game/SPetInfo";
import { PetUtil } from "../info/PetUtil";
import { SkillConfig } from "../../../resource/SkillConfig";
//class PetExtendPreviewPanel
    
    export  class PetExtendPreviewPanel extends BgLabelToolTip
    {
        constructor(arg1: string="")
        {
            super(arg1);
            this._txtArray = [];
            this._attrLString = Language.getString(54064);
            this._attrLabelArray = this._attrLString.split(",");
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            this._bg.setSize(130, 270);
            this._contentSprite = new Object /* flash.display.Sprite */();
            this._contentSprite.x = 10;
            this._contentSprite.y = 10;
            this.addChild(this._contentSprite);
            this._nameTxt = ObjCreate.createTextField("", 0, 0, 220, 20, this._contentSprite);
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            loc3 = 0;
            while (loc3 < this._attrLabelArray.length) 
            {
                loc1 = ObjCreate.createTextField(this._attrLabelArray[loc3], 0, 20 + loc3 * 20, 220, 20, this._contentSprite);
                loc1.autoSize = flash.text.TextFieldAutoSize.LEFT;
                loc2 = ObjCreate.createTextField("", 60, 20 + loc3 * 20, 220, 20, this._contentSprite, GlobalStyle.textFormat2);
                loc2.autoSize = flash.text.TextFieldAutoSize.LEFT;
                if (loc3 < 4) 
                {
                    loc1.y = 20 + loc3 * 20;
                    loc2.y = 20 + loc3 * 20;
                }
                else 
                {
                    loc1.y = 30 + loc3 * 20;
                    loc2.y = 30 + loc3 * 20;
                }
                this._txtArray.push(loc2);
                ++loc3;
            }
            this._skillTxt = ObjCreate.createTextField("", 0, 260, 220, 20, this._contentSprite);
            this._skillTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            return;
        }

        /* internal  */updateByValueArray(arg1: Array<any>): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < arg1.length) 
            {
                loc1 = this._txtArray[loc2];
                loc1.text = arg1[loc2].toString();
                ++loc2;
            }
            return;
        }

        public updateByPetInfo(arg1: SPetInfo): void
        {
            var loc1=[];
            if (arg1) 
            {
                this._nameTxt.htmlText = PetUtil.getPetName(arg1);
                loc1.push(arg1.talent);
                loc1.push(Language.getStringByParam(28023, arg1.reinLevel, arg1.level));
                loc1.push(arg1.growth);
                loc1.push(arg1.spirit);
                loc1.push(arg1.fightAttribute.physicalAttack);
                loc1.push(arg1.fightAttribute.magicAttack);
                loc1.push(arg1.fightAttribute.physicalDefense);
                loc1.push(arg1.fightAttribute.magicDefense);
                loc1.push(arg1.fightAttribute.hit);
                loc1.push(arg1.fightAttribute.jouk);
                loc1.push(arg1.fightAttribute.physicalCrit + arg1.fightAttribute.magicCrit);
                this.updateByValueArray(loc1);
                this._skillTxt.htmlText = "<textFormat leading=\'5\'>" + this.getSkillData(arg1) + "</textFormat>";
                this._bg.setSize(130, this._contentSprite.height + 15);
            }
            return;
        }

        /* internal  */getSkillData(arg1: SPetInfo): string
        {
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc1="";
            if (arg1) 
            {
                loc4 = 0;
                while (loc4 < arg1.skills.length) 
                {
                    loc2 = arg1.skills[loc4];
                    loc3 = SkillConfig.instance.getInfoByName(loc2.skillId);
                    loc1 = loc1 + (loc3.skillName + "\n");
                    ++loc4;
                }
            }
            return loc1;
        }

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_skillTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_contentSprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_txtArray: Array<any>;

        /* internal */ /* var */_attrLString: string;

        /* internal */ /* var */_attrLabelArray: Array<any>;
    }
